|
|
|
|
|
|
|
Figure 2.14
Program FillMode demonstrates polygon fill modes. |
|
|
|
|
|
|
|
|
The FloodFill function fills an area of the screen using the current brush. The fill begins at the point (X, Y) and continues in all directions until the function encounters a pixel with the color crColor. At that point, the function stops filling in that direction. The following code shows how to declare the FloodFill function in Visual Basic. |
|
|
|
 |
|
|
|
|
Private Declare Function FloodFill Lib "gdi32" _
Alias "FloodFill' (ByVal hdc As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal crColor As Long) As Long |
|
|
|
|
|
|
|
|
Example program Flood, shown in Figure 2.15, demonstrates the FloodFill API function. When you click on the form, the program fills the area you clicked using a random color. |
|
|
|
|
|
|
|
|
The ExtFloodFill function is similar to FloodFill except it takes an extra parameter that determines how the fill progresses. If you set the wFillType parameter to FLOODFILLBORDER, the fill stops when it finds a pixel with color crColor (exactly as before). If you set wFillType to FLOODFILLSURFACE, the fill continues as long as the function finds pixels that do have the specified color rather than as long as they do not have that color. This approach can be useful when you want to fill an object that has a single color but that has a multicolored boundary. |
|
|
|
 |
|
|
|
|
Private Const FLOODFILLBORDER = 0
Private Const FLOODFILLSURFACE = 1
Private Declare Function ExtFloodFill Lib "gdi32" _
Alias "ExtFloodFill" (ByVal hdc As Long, _ |
|
|
|
|
|